<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>编辑用户信息</title>
</head>
<body>
<div style="margin-left: 50%">
    <form id="form-edit" th:action="@{/editUser}" method="post">
        <input type="hidden" name="id" th:value="${user.id}">
        <div>
            用户名：<input id="username" name="username" type="text" th:value="${user.username}">
        </div>
        <div>
            学院：<input id="institute" name="institute" type="text" th:value="${user.institute}">
        </div>
        <div>
            姓名：<input id="name" name="name" type="text" th:value="${user.name}">
        </div>
        <div>
            状态：
            <input type="radio" name="state" value="false" th:checked="${user.state == false}">禁用
            <input type="radio" name="state" value="true" th:checked="${user.state == true}">启用
        </div>
        <div>
            是否为管理员：
            <input type="radio" name="isAdmin" value="false" th:checked="${user.isAdmin == false}">否
            <input type="radio" name="isAdmin" value="true" th:checked="${user.isAdmin == true}">是
        </div>
        <div>
            修改密码：<input id="password" name="password" type="password" th:value="${user.password}">
        </div>
        <div>
            确认密码：<input id="rePassword" name="rePassword" type="password" th:value="${user.password}">
        </div>
        <div>
            <input type="submit" class="button" value="保存">
        </div>
    </form>
</div>
<div th:include="common :: common"></div>
</body>
</html>
<script>
    $(function () {
        $("#form-edit").validate({
            submitHandler: function(form){
                form.submit();   //提交表单
            },
            rules:{
                institute:{
                    required: true
                },
                username:{
                    required: true
                },
                name:{
                    required: true
                },
                isAdmin:{
                    required: true
                },
                state:{
                    required: true
                },
                password:{
                    required: true
                },
                rePassword:{
                    required: true,
                    equalTo: "#password"
                }
            },
            focusCleanup: true
        });
    });
</script>